home *** CD-ROM | disk | FTP | other *** search
- /*
- * Source machine generated by GadToolsBox V2.0b
- * which is (c) Copyright 1991-1993 Jaba Development
- *
- * GUI Designed by : Yannick Koehler
- */
-
- #include <exec/types.h>
- #include <intuition/intuition.h>
- #include <intuition/intuitionbase.h>
- #include <intuition/classes.h>
- #include <intuition/classusr.h>
- #include <intuition/imageclass.h>
- #include <intuition/gadgetclass.h>
- #include <libraries/gadtools.h>
- #include <graphics/displayinfo.h>
- #include <graphics/gfxbase.h>
- #include <clib/exec_protos.h>
- #include <clib/intuition_protos.h>
- #include <clib/gadtools_protos.h>
- #include <clib/graphics_protos.h>
- #include <clib/utility_protos.h>
- #include <string.h>
- #include <clib/diskfont_protos.h>
-
- #include <pragmas/exec_pragmas.h>
- #include <pragmas/intuition_pragmas.h>
- #include <pragmas/gadtools_pragmas.h>
- #include <pragmas/graphics_pragmas.h>
- #include <pragmas/utility_pragmas.h>
-
- #include "gui.h"
-
- struct Screen *Scr = NULL;
- UBYTE *PubScreenName = NULL;
- APTR VisualInfo = NULL;
- struct Window *SMWnd = NULL;
- struct Gadget *SMGList = NULL;
- struct Gadget *SMGadgets[2];
- UWORD SMWidth = 372;
- UWORD SMHeight = 87;
- UBYTE *SMWdt = "ScreenMenu V1.2 by Yannick Koehler";
- struct TextAttr *Font, Attr;
- UWORD FontX, FontY;
- UWORD OffX, OffY;
- struct TextFont *SMFont = NULL;
-
- UBYTE *Gadget100Labels[] = {
- (UBYTE *)"Normal Screen Name",
- (UBYTE *)"Public Screen Name",
- /*(UBYTE *)"EGS Screen Name",*/
- NULL
- };
-
- UWORD SMGTypes[] = {
- LISTVIEW_KIND,
- CYCLE_KIND
- };
-
- struct NewGadget SMNGad[] = {
- 5, 16, 362, 72, NULL, NULL, GD_Gadget00, 0, NULL, (APTR)1L,
- 5, 3, 362, 13, NULL, NULL, GD_Gadget10, 0, NULL, (APTR)2L
- };
-
- ULONG SMGTags[] = {
- (GTLV_ShowSelected), NULL, (GTLV_ScrollWidth), 17, (GTLV_Selected), 0, (TAG_DONE),
- (GTCY_Labels), (ULONG)&Gadget100Labels[ 0 ], (TAG_DONE)
- };
-
- static UWORD ComputeX( UWORD value )
- {
- return(( UWORD )((( FontX * value ) + 4 ) / 8 ));
- }
-
- static UWORD ComputeY( UWORD value )
- {
- return(( UWORD )((( FontY * value ) + 4 ) / 8 ));
- }
-
- static void ComputeFont( UWORD width, UWORD height )
- {
- Forbid();
- Font = &Attr;
- Font->ta_Name = (STRPTR)GfxBase->DefaultFont->tf_Message.mn_Node.ln_Name;
- Font->ta_YSize = FontY = GfxBase->DefaultFont->tf_YSize;
- FontX = GfxBase->DefaultFont->tf_XSize;
- Permit();
-
- OffX = Scr->WBorLeft;
- OffY = Scr->RastPort.TxHeight + Scr->WBorTop + 1;
-
- if ( width && height ) {
- if (( ComputeX( width ) + OffX + Scr->WBorRight ) > Scr->Width )
- goto UseTopaz;
- if (( ComputeY( height ) + OffY + Scr->WBorBottom ) > Scr->Height )
- goto UseTopaz;
- }
- return;
-
- UseTopaz:
- Font->ta_Name = (STRPTR)"topaz.font";
- FontX = FontY = Font->ta_YSize = 8;
- }
-
- int SetupScreen( void )
- {
- ULONG num;
-
- num = LockIBase(0);
- Scr = IntuitionBase->FirstScreen;
- UnlockIBase(num);
-
- ComputeFont( 0, 0 );
-
- if ( ! ( VisualInfo = GetVisualInfo( Scr, TAG_DONE )))
- return( 2L );
-
- return( 0L );
- }
-
- void CloseDownScreen( void )
- {
- if ( VisualInfo ) {
- FreeVisualInfo( VisualInfo );
- VisualInfo = NULL;
- }
-
- Scr = NULL;
- }
-
- int OpenSMWindow( void )
- {
- struct NewGadget ng;
- struct Gadget *g;
- UWORD lc, tc;
- UWORD wleft = Scr->MouseX-4, wtop = Scr->MouseY-17, ww, wh;
- UWORD rleft, rtop;
-
- ComputeFont( SMWidth, SMHeight );
-
- ww = ComputeX( SMWidth );
- wh = ComputeY( SMHeight );
-
- if (( wleft + ww + OffX + Scr->WBorRight ) > Scr->Width ) wleft = Scr->Width - ww;
- if (( wtop + wh + OffY + Scr->WBorBottom ) > Scr->Height ) wtop = Scr->Height - wh;
-
- rleft = (((wleft - OffX) == 0) || ((wleft - OffX) > (Scr->Width-1 ))) ? 0 : wleft - OffX;
- rtop = (((wtop - OffY) == 0) || ((wtop - OffY) > (Scr->Height-1))) ? 0 : wtop - OffY;
-
- if ( ! ( SMFont = OpenDiskFont( Font )))
- return( 5L );
-
- if ( ! ( g = CreateContext( &SMGList )))
- return( 1L );
-
- for( lc = 0, tc = 0; lc < SM_CNT; lc++ ) {
-
- CopyMem((char * )&SMNGad[ lc ], (char * )&ng, (long)sizeof( struct NewGadget ));
-
- ng.ng_VisualInfo = VisualInfo;
- ng.ng_TextAttr = Font;
- ng.ng_LeftEdge = OffX + ComputeX( ng.ng_LeftEdge );
- ng.ng_TopEdge = OffY + ComputeY( ng.ng_TopEdge );
- ng.ng_Width = ComputeX( ng.ng_Width );
- ng.ng_Height = ComputeY( ng.ng_Height);
-
- SMGadgets[ lc ] = g = CreateGadgetA((ULONG)SMGTypes[ lc ], g, &ng, ( struct TagItem * )&SMGTags[ tc ] );
-
- while( SMGTags[ tc ] ) tc += 2;
- tc++;
-
- if ( NOT g )
- return( 2L );
- }
-
- if ( ! ( SMWnd = OpenWindowTags( NULL,
- WA_Left, rleft,
- WA_Top, rtop,
- WA_Width, ww + OffX + Scr->WBorRight,
- WA_Height, wh + OffY + Scr->WBorBottom,
- WA_IDCMP, LISTVIEWIDCMP|CYCLEIDCMP|IDCMP_INACTIVEWINDOW|IDCMP_MOUSEBUTTONS|IDCMP_RAWKEY,
- WA_Flags, WFLG_NOCAREREFRESH|WFLG_ACTIVATE|WFLG_RMBTRAP|WFLG_REPORTMOUSE,
- WA_Gadgets, SMGList,
- WA_Title, SMWdt,
- WA_CustomScreen, Scr,
- WA_AutoAdjust, TRUE,
- TAG_DONE )))
- return( 4L );
-
- GT_RefreshWindow( SMWnd, NULL );
-
- return( 0L );
- }
-
- void CloseSMWindow( void )
- {
- if ( SMWnd ) {
- CloseWindow( SMWnd );
- SMWnd = NULL;
- }
-
- if ( SMGList ) {
- FreeGadgets( SMGList );
- SMGList = NULL;
- }
-
- if ( SMFont ) {
- CloseFont( SMFont );
- SMFont = NULL;
- }
- }
-
-